<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ProjectUser extends Model
{
    use HasFactory;

    protected $fillable = ['project_id','user_id','role_id','roles','cert_id','price','social_security','year_end_bonus','balance','start_date','end_date','post','month','work','remarks','status'];

    const POSTONLY = ['project_id','user_id','role_id','roles','cert_id','price','social_security','year_end_bonus','balance','start_date','end_date','post','month','work','remarks','status'];
    
    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }

    public function project()
    {
        return $this->hasOne(Project::class,'id','project_id')->select('id','title','status');
    }

    public function user()
    {
        return $this->hasOne(User::class,'id','user_id')->select('id','name','mobile');
    }

    public function role()
    {
        return $this->hasOne(Role::class,'id','role_id')->select('id','name');
    }

    public function cert()
    {
        return $this->hasOne(Cert::class,'id','cert_id');
    }

    
    
}
